<?php
/**
 * Created by PhpStorm.
 * User: Shine
 * Date: 2019-02-23
 * Time: 15:17
 */

namespace app\m\controller;

use think\Db;


class School
{

    /*
     * 学校首页
     */
    public function home()
    {


    }

    /**
     * 学校搜索
     */
    public function srh()
    {
        $ses = session('ses');
        if (!$ses) {
            echo '{"err":1,"msg":"auth error"}';
            return;
        }
        $uid = $ses['uid'];
        $scid = isset($_GET['scid']) ? intval($_GET['scid']) : 0;

        $scid = 1;

        $sch = null;
        if ($scid) {
            $qs = Db::query('select id,name from x1_school where id=? limit 0,1', [$scid]);
            $sch = $qs ? $qs[0] : [];
        }
        $loc = true;
        $locAuth = false;

        $pos = ['addr' => '正在获取位置信息...', 'c' => '', 'loc' => $loc, 'locAuth' => $locAuth];

        // $list = Db::query('select s.id,s.name from x1_role_apply a left join x1_school s on a.pid=s.id where a.uid=? and a.type in (2,3)', [$uid]);
        // $list = array_unique($list, SORT_REGULAR);

        $list = [];

        echo json_encode(['err' => 0, 'msg' => '获取成功', 'sch' => $sch, 'list' => $list, 'pos' => $pos]);
    }


}
